package com.purplesoft.zettl.DatabaseViews;

import android.provider.BaseColumns;

import com.purplesoft.zettl.DatabaseTables.TblCategories;
import com.purplesoft.zettl.DatabaseTables.TblItems;
import com.purplesoft.zettl.DatabaseTables.TblManufacturer;
import com.purplesoft.zettl.DatabaseTables.TblMeasures;

public class VwItems {

	public class Columns implements BaseColumns {

		// columns of view "vwItems"
		public static final String Item = "Item";
		public static final String ItemDescription = "Description";
		public static final String ItemImg = "ItemImg";
		public static final String ManufacturerID = "ManufacturerID";
		public static final String Manufacturer = "Manufacturer";
//		public static final String PriceID = "PriceID";
		public static final String Price = "Price";
		public static final String CategoryID = "CategoryID";
		public static final String CategoryName = "CategoryName";
		public static final String MeasureID = "MeasureID";
		public static final String Measure = "Measure";
		public static final String MeasureShort = "MeasureShort";
		public static final String Min = "Min";
		public static final String Max = "Max";
		public static final String IncreaseBy = "IncreaseBy";
		public static final String PricePer = "PricePer";
		public static final String Notes = "Notes";

	}

	public static final String viewName = "vwItems";
	public static final String CONTENT_TYPE = "vnd.android.cursor.dir/com.purplesoft.zettl.vwItems";

	public static final String createView = "CREATE VIEW " + viewName
			+ " AS SELECT i." + Columns._ID 
			+ ", i." + Columns.Item 
			+ ", i." + Columns.ItemDescription 
			+ ", i." + Columns.ItemImg 
			+ ", m." + Columns.Manufacturer
			+ ", i." + Columns.Price 
			+ ", c." + Columns.CategoryName 
			+ ", me." + Columns.Measure
			+ ", me." + Columns.MeasureShort
			+ ", me." + Columns.Min
			+ ", me." + Columns.Max
			+ ", me." + Columns.IncreaseBy
			+ ", me." + Columns.PricePer
			+ ", i." + Columns.Notes 
			+ " FROM "
			+ TblItems.tableName + " i, " 
			+ TblMeasures.tableName + " me, "
			+ TblCategories.tableName + " c, "
			+ TblManufacturer.tableName + " m WHERE i." + TblItems.Columns.ManufacturerID + " = m."	+ TblManufacturer.Columns._ID 
			+ " and i." + TblItems.Columns.MeasureID + " = me." + TblMeasures.Columns._ID
			+ " and i." + TblItems.Columns.CategoryID + " = c." + TblCategories.Columns._ID;

}
